var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function () {
        var t = function (e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function (e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })();
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("ConfS"),
    a = t("PlatformCtrl_web"),
    i = t("Platforms"),
    s = (function (t) {
        function e() {
            var e = t.call(this) || this;
            return (
                (e.rewardAd_show = function () {
                    e.ts2native("showRewardAd");
                }),
                (e.insertAd_show = function () {
                    e.ts2native("showInsertAd");
                }),
                (e.bannerAd_show = function (t) {
                    e.ts2native("showBannerAd", {
                        dx: t.dx,
                        dy: t.dy,
                        offsetX: t.offsetX * e.物理屏幕和画布的比例,
                        offsetY: t.offsetY * e.物理屏幕和画布的比例
                    });
                }),
                (e.bannerAd_hide = function () {
                    e.ts2native("hideBannerAd");
                }),
                (e.nativeAd_show = function (t) {
                    e.ts2native("showNativeAd", {
                        dx: t.dx,
                        dy: t.dy,
                        offsetX: t.offsetX * e.物理屏幕和画布的比例,
                        offsetY: t.offsetY * e.物理屏幕和画布的比例
                    });
                }),
                (e.nativeAd_hide = function () {
                    e.ts2native("hideNativeAd");
                }),
                (e.openId = ""),
                (i.default.userStorage.openId = ""),
                e
            );
        }
        return (
            n(e, t),
            (e.prototype.获取物理参数 = function () {
                (this.language = navigator.language), (this.粪叉 = !1);
            }),
            (e.prototype.native_init = function (t) {
                this._init(t), this.ts2native("ready");
            }),
            (e.prototype.login = function (t) {
                (this.onLoginComplete = t), this.openId && this._login();
            }),
            (e.prototype._login = function () {
                (i.default.userStorage.openId = this.openId),
                    i.default.userStorage.setDirty(),
                    t.prototype.login.call(this, this.onLoginComplete),
                    (this.onLoginComplete = null);
            }),
            (e.prototype._openCPB = function (t, e, o) {
                cc.sys.openURL(cc.sys.os == cc.sys.OS_IOS ? t.appId : t.andURL), e({errMsg: ""});
            }),
            (e.prototype.exit = function () {
                this.ts2native("exit");
            }),
            (e.prototype.pay = function (t, e) {
                (this.payCallback = e), this.ts2native("pay", {sku: t});
            }),
            (e.prototype.ts2native = function (t, e) {
                e ? (e.op = t) : (e = {op: t});
                var o = JSON.stringify(e);
                console.log("ts2native 发送：" + o),
                    cc.sys.os == cc.sys.OS_IOS
                        ? jsb.reflection.callStaticMethod("NativeTS", "ts2native:", o)
                        : jsb.reflection.callStaticMethod(
                              "org/cocos2dx/javascript/NativeTS",
                              "ts2native",
                              "(Ljava/lang/String;)V",
                              o
                          );
            }),
            (e.prototype.native2ts = function (t) {
                console.log("native2ts 接收：" + t);
                var e = JSON.parse(t);
                switch (e.op) {
                    case "readyCallback":
                        (this.openId = e.openId), this.onLoginComplete && this._login();
                        break;
                    case "setPrices":
                        for (var o = 0, n = r.DatasManager.ChargeDatas; o < n.length; o++) {
                            (s = n[o]).LocalPrice = "???";
                        }
                        for (var a = 0, i = e.prices.split("\n"); a < i.length; a++) {
                            var s,
                                c = i[a].match(/(\d+) (\S.*\S)/);
                            if (c) (s = r.DatasManager.ChargeDatas[parseInt(c[1]) - 1]) && (s.LocalPrice = c[2]);
                        }
                        break;
                    case "payCallback":
                        this.payCallback &&
                            (this.payCallback("true" == e.success), (this.payCallback = null), this.setStore());
                        break;
                    case "rewardAdLoaded":
                        break;
                    case "rewardAdClose":
                        this.rewardAdCtrl.close("true" == e.success);
                        break;
                    case "rewardAdError":
                        this.rewardAdCtrl.error();
                        break;
                    case "insertAdClose":
                        break;
                    default:
                        console.error("未知 op：" + e.op);
                }
            }),
            e
        );
    })(a.default);
o.default = s;
